package com.cop.consultapp.activity;

import com.kdn.consaltapp.R;
import com.kdn.consaltapp.R.layout;
import com.kdn.consaltapp.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ConsultInsertActivity extends Activity {
	
	private Button btnHome = null;
	private Button btnSave = null;
	private Button btnCancel = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_consult_insert);
		
		setView();
	}

	private void setView(){
		//버튼 객체에 값 할당
		this.btnHome=(Button)findViewById(R.id.parkBtnInsertHome);
		this.btnSave=(Button)findViewById(R.id.parkBtnInsertSave);
		this.btnCancel=(Button)findViewById(R.id.parkBtnInsertCancel);
		
		setBtnHomeOnClickListener();
		setBtnSaveOnClickListener();
		setBtnCancelOnClickListener();
		
	}
	private android.content.DialogInterface.OnClickListener positiveOnClickListener = new android.content.DialogInterface.OnClickListener() {
		
		@Override
		public void onClick(DialogInterface arg0, int arg1) {
			// TODO Auto-generated method stub
			finish();
		}
	};
	
	private android.content.DialogInterface.OnClickListener negativeOnClickListener = new android.content.DialogInterface.OnClickListener() {
		
		@Override
		public void onClick(DialogInterface arg0, int arg1) {
			// TODO Auto-generated method stub
			
		}
	};
	
	@Override
	public boolean onKeyUp(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		Log.d("mylog", "key------------------->" +keyCode);
		if(keyCode == KeyEvent.KEYCODE_BACK){
			return false;
		}else{
			return super.onKeyUp(keyCode, event);
		}
		
		
	}

	private void setBtnHomeOnClickListener(){
		this.btnHome.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				new AlertDialog.Builder(ConsultInsertActivity.this)
				.setTitle("팝업타이틀")
				.setMessage("Home으로 이동하시겠습니까?")
				.setIcon(R.drawable.ic_launcher)
				.setCancelable(false)
				.setPositiveButton("예", positiveOnClickListener)
				.setNegativeButton("아니오", negativeOnClickListener)
				.show();
				
				//finish();
			}
		});
	}
	
	private void setBtnSaveOnClickListener(){
		this.btnSave.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//Intent intent=new Intent(getApplicationContext(), ConsultInsertActivity.class);
				
				
				//startActivity(intent);
			}
		});
	}
	
	private void setBtnCancelOnClickListener(){
		this.btnCancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
	}
	
	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		Log.d("mylog","insert :: finish");
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		Log.d("mylog","insert :: onDestroy");
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		Log.d("mylog","insert :: onPause");
	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
		Log.d("mylog","insert :: onRestart");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.d("mylog","insert :: onResume");
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		Log.d("mylog","insert :: onStart");
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		Log.d("mylog","insert :: onStop");
	}
	
}
